package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Systemdictionaryitem;
import cn.wolfcode.mapper.SystemdictionaryitemMapper;
import cn.wolfcode.qo.QueryObject;
import cn.wolfcode.service.ISystemdictionaryitemService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemdictionaryitemServiceImpl implements ISystemdictionaryitemService {

    @Autowired
    private SystemdictionaryitemMapper systemdictionaryitemMapper;


    @Override
    public void save(Systemdictionaryitem systemdictionaryitem) {
        systemdictionaryitemMapper.insert(systemdictionaryitem);
    }

    @Override
    public void delete(Long id) {
        systemdictionaryitemMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Systemdictionaryitem systemdictionaryitem) {
        systemdictionaryitemMapper.updateByPrimaryKey(systemdictionaryitem);
    }

    @Override
    public Systemdictionaryitem get(Long id) {
        return systemdictionaryitemMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Systemdictionaryitem> listAll() {
        return systemdictionaryitemMapper.selectAll();
    }

    @Override
    public PageInfo<Systemdictionaryitem> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),"sequence asc"); //对下一句sql进行自动分页
        List<Systemdictionaryitem> systemdictionaryitems = systemdictionaryitemMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<Systemdictionaryitem>(systemdictionaryitems);
    }

    @Override
    public List<Systemdictionaryitem> selectByParentSn(String sn) {
        return systemdictionaryitemMapper.selectByParentSn(sn);
    }
}
